PROJECT(imagebrowser)


FIND_PACKAGE(Qt4 REQUIRED)
SET( QT_USE_QTGUI   TRUE )
INCLUDE( ${QT_USE_FILE} )
INCLUDE_DIRECTORIES(
      ${CMAKE_CURRENT_SOURCE_DIR} 
      ${QT_INCLUDE_DIR}
      ${CMAKE_CURRENT_BINARY_DIR}
      )

SET(UI
  windowbase.ui 
  )

QT4_WRAP_UI(UI_H ${UI})

ADD_CUSTOM_TARGET(ui ALL DEPENDS ${UI_H})

SET(SRCS
      main.cpp 
      window.cpp
      imageeffect.cpp
      ${UI_H}
     )

SET(MOC_HDRS
  window.h
  )

QT4_WRAP_CPP(MOC_SRCS ${MOC_HDRS})



ADD_EXECUTABLE(imagebrowser
      MACOSX_BUNDLE
      ${SRCS} 
      ${MOC_SRCS} 
      )

TARGET_LINK_LIBRARIES(imagebrowser
      ${QT_QTGUI_LIBRARY} 
      ${QT_QTCORE_LIBRARY} 
      )

INSTALL(TARGETS imagebrowser RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})

FILE (GLOB IMAGES images/*.jpg)

IF (APPLE) #mac needs special treatment
  INSTALL (FILES ${IMAGES} DESTINATION
    ${CMAKE_INSTALL_PREFIX}/imagebrowser.app/Contents/MacOS/images)
ELSE (APPLE) #other operating systems
  INSTALL (FILES ${IMAGES}
           DESTINATION ${CMAKE_INSTALL_PREFIX}/images)
ENDIF (APPLE)

SUBDIRS (doc)

#########################################################
# Unit testing
#########################################################
# First we set up things to includes and linking for QtTest work
SET( QT_USE_QTTEST  TRUE )
SET( QT_USE_QTGUI   TRUE )
INCLUDE( ${QT_USE_FILE} )
INCLUDE_DIRECTORIES(
      ${CMAKE_CURRENT_SOURCE_DIR} 
      ${QT_INCLUDE_DIR}
      ${CMAKE_CURRENT_BINARY_DIR}
      )
# Now we enable CTest in CMake    
ENABLE_TESTING()

#
# Now for each test we implement a block like the one below...
#

#
# ImageEffect test
#
SET(imageeffecttest_SRCS imageeffecttest.cpp imageeffect.cpp)
SET(imageeffecttest_MOC_CPPS ${imageeffecttest_SRCS})
QT4_WRAP_CPP(imageeffecttest_MOC_SRCS ${imageeffecttest_MOC_CPPS})
ADD_CUSTOM_TARGET(imageeffecttestmoc ALL DEPENDS ${imageeffecttest_MOC_SRCS})
ADD_EXECUTABLE(imageeffecttest ${imageeffecttest_SRCS})
ADD_DEPENDENCIES(imageeffecttest imageeffecttestmoc)
TARGET_LINK_LIBRARIES(imageeffecttest ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
INSTALL(TARGETS imageeffecttest RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
ADD_TEST(imageeffecttest ${CMAKE_INSTALL_PREFIX}/imageeffecttest)

